package com.woniuxy.oldmanapi.service;

import com.woniuxy.oldmanapi.entity.Building;
import com.woniuxy.oldmanapi.mapper.BedMapper;
import com.woniuxy.oldmanapi.mapper.BuildingMapper;
import com.woniuxy.oldmanapi.mapper.RoomMapper;
import com.woniuxy.oldmanapi.mapper.StoreyMapper;
import com.woniuxy.oldmanapi.xvo.StoreyDyaVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import com.woniuxy.oldmanapi.entity.Bed;
import com.woniuxy.oldmanapi.mapper.BedMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedService {
    @Autowired
    StoreyMapper storeyMapper;
    @Autowired
    RoomMapper roomMapper;
    @Autowired
    BedMapper bedMapper;
    @Autowired
    BuildingMapper buildingMapper;

    public List<StoreyDyaVo> selectBedDyaVoByBuid(int buildingId) {
        List<StoreyDyaVo> storeyDyaVoList = storeyMapper.selectBedDyaVoByBuid(buildingId);
        return storeyDyaVoList;
    }

    public List<Building> selectAllBuilding() {
        return buildingMapper.selectAll();
    }

    public List<StoreyDyaVo> searchStoreyByState0(int buildingId) {
        List<StoreyDyaVo> storeyDyaVoList = storeyMapper.searchStoreyByState0(buildingId);
        return storeyDyaVoList;
    }

    public List<StoreyDyaVo> searchStoreyByState1(int buildingId) {
        List<StoreyDyaVo> storeyDyaVoList = storeyMapper.searchStoreyByState1(buildingId);
        return storeyDyaVoList;
    }

    public int selectBedAccount(int state) {
        int account = bedMapper.selectBedAccount(state);
        return account;
    }
    public List<Bed> findBeds(int id) {
        List<Bed> BedList =  bedMapper.selectById(id);
        return BedList;
    }
    public void add(Bed bed) {
        bedMapper.insert(bed);
    }

    public void delete(int id) {
        bedMapper.deleteByPrimaryKey(id);
    }

    public void modify(Bed bed) {
        bedMapper.updateByPrimaryKey(bed);
    }

    public Bed selectOne(int id) {
        return bedMapper.selectByPrimaryKey(id);
    }

    public int findBedNum(int id) {
        return bedMapper.selectNum(id);
    }
}
